<!DOCTYPE html	PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	template="/template/template_layout_lr.xhtml"
	xmlns:s="http://sduept.security.el/func">
	<ui:define name="head">
		<style>
.ui-button, .ui-button span, button.ui-button.ui-state-default span,
	.ui-button.ui-state-default span {
	font-weight: normal
}
.ui-widget-fa {
	font-family: "Microsoft JhengHei";
	font-weight: bold;
	font-size: 1.15em;
}

.ui-commandlink-fa {
	font-family: FontAwesome;
}
#createform .ui-fileupload-content, #editForm .ui-fileupload-content {
	display: none;
}

#createform .ui-fileupload-buttonbar, #editForm .ui-fileupload-buttonbar
	{
	background: white;
	border: none;
}
</style>
	</ui:define>
	<ui:define name="left-box-title">
		管控区域
	</ui:define>
	<ui:define name="left-box-body">
		<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
			<p:commandButton value="是" type="button"
				styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
			<p:commandButton value="否" type="button"
				styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
		</p:confirmDialog>
		<div class="box-header with-border">
			<h:form id="form1">
				<p:growl id="msgs" showDetail="true" />
				<p:autoComplete placeholder="输入区域首字母可查" id="ctrlArea_id" size="20"
					value="#{personAndEquipmentDistributeController.ctrlArea}"
					completeMethod="#{personAndEquipmentDistributeController.completeCtrlArea}"
					scrollHeight="400" style="float:left;">
					<p:ajax update="ctrlArea_id :leftForm:tree" event="itemSelect"
						listener="#{personAndEquipmentDistributeController.autoComplete}" />
				</p:autoComplete>
				<p:commandButton icon="fa fa-refresh"
					style="margin-left:3px;height:30px;"
					update="ctrlArea_id :leftForm:tree"
					actionListener="#{personAndEquipmentDistributeController.init()}" />
			</h:form>
		</div>
		<div class="box-body  with-border">
			<h:form id="leftForm">
				<p:tree value="#{personAndEquipmentDistributeController.areaRoot}"
					var="node" dynamic="true" id="tree" widgetVar="tree" animate="true"
					selectionMode="single" style="border:0">
					<p:ajax event="select" update=":rightForm:plist "
						listener="#{personAndEquipmentDistributeController.onNodeSelect}" />
					<p:ajax event="unselect" update=":rightForm:plist "
						listener="#{personAndEquipmentDistributeController.onNodeUnSelect}" />
					<p:treeNode type="subControlArea" icon="fa fa-home">
						<h:outputText value="#{node}" />
					</p:treeNode>
				</p:tree>
			</h:form>
		</div>
	</ui:define>
	<ui:define name="right-box-title">
		变电站列表
	</ui:define>
	<ui:define name="right-box-body">
		<div id="div1">
			<h:form id="rightForm">
				<p:toolbar>
					<f:facet name="left">
						<p:outputLabel value="电压等级：" style="margin-right:5px" />
						<h:selectOneMenu id="vol"
							value="#{personAndEquipmentDistributeController.selectdStandVolLevel}"
							style="width:100px;height:30px;margin-right:10px">
							<f:selectItem itemLabel="全部" itemValue="" />
							<f:selectItems value="#{personAndEquipmentDistributeController.standVoltageLevels}" />
						</h:selectOneMenu>
						<p:commandButton icon="ui-icon-search" value="查询"
							actionListener="#{personAndEquipmentDistributeController.query()}"
							update="rightForm:plist" style="margin-left:5px;" />
					</f:facet>
					<f:facet name="right">
						<p:commandButton id="addBtn" icon="fa fa-plus" value="分配管理者" style="margin-right:5px;margin-left:5px" 
							rendered="#{s:hasPermission(session,'xtsz_bdzglrypz_fpglz')}"
							actionListener="#{personAndEquipmentDistributeController.preDistribute()}"
							disabled="#{personAndEquipmentDistributeController.selectSubStations.size()==0}"
							oncomplete="PF('addGovernorDialog').show()"
							update=":dialogForm:orgTree :form1:msgs :dialogForm:personCol" />
						<p:commandButton value="移除管理者" icon="fa fa-trash"
							rendered="#{s:hasPermission(session,'xtsz_bdzglrypz_ycglz')}"
							style="margin-left:5px;" id="deleteBtn"
							disabled="#{personAndEquipmentDistributeController.selectSubStations.size()==0}"
							update="rightForm:plist rightForm:deleteBtn rightForm:addBtn :form1:msgs"
							actionListener="#{personAndEquipmentDistributeController.delete}" >
							<p:confirm header="提示" message="确定移除吗?" icon="ui-icon-alert" />
						</p:commandButton>
					</f:facet>
				</p:toolbar>
				<p:dataTable id="plist" var="station" rowKey="#{station.id}"
					emptyMessage="无记录" rowIndexVar="ite"
					value="#{personAndEquipmentDistributeController.subStations}"
					selection="#{personAndEquipmentDistributeController.selectSubStations}"
					lazy="false" rows="20" paginator="true" paginatorPosition="bottom"
					paginatorTemplate="{Customization} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					rowsPerPageTemplate="20,50,100" >
					<f:facet name="{Customization}">
						<p:outputLabel style="margin-right:20px"
							value="总计：#{personAndEquipmentDistributeController.subStations.size()}条纪录" />
					</f:facet>
					<p:ajax event="rowSelectCheckbox" process="@all" update="rightForm:addBtn rightForm:deleteBtn" />
					<p:ajax event="rowUnselectCheckbox" process="@all" update="rightForm:addBtn rightForm:deleteBtn" />
					<p:ajax event="rowSelect" process="@all" update="rightForm:addBtn rightForm:deleteBtn" />
					<p:column selectionMode="multiple"
						style="text-align:center;width:60px" />
					<p:column headerText="序号 " style="width:60px;text-align:center">
						<h:outputText value="#{ite+1}" />
					</p:column>
					<p:column headerText="变电站名称" style="text-align:center;width:16%">
						<h:outputText value="#{station.name}" />
					</p:column>
					<p:column headerText="调管单位" style="text-align:center;width:17%">
						<h:outputText
							value="#{personAndEquipmentDistributeController.getDispatchUnit(station.id)}" />
					</p:column>
					<p:column headerText="运维单位" style="text-align:center;width:17%">
						<h:outputText
							value="#{personAndEquipmentDistributeController.getMaintenanceUnit(station.id)}" />
					</p:column>
					<p:column headerText="电压等级" style="text-align:center;width:10%">
						<h:outputText value="#{station.standVoltagelevel}" />
					</p:column>
					<p:column headerText="管理人员" style="text-align:center;width:25%">
						<p:repeat var="pd" value="#{personAndEquipmentDistributeController.getStationDistribute(station)}">
							<div style="float:left;width:80px">
								<h:outputText
									value="#{personAndEquipmentDistributeController.getStationGovernor(pd.personId)}" />
								<p:commandLink title="移除人员" styleClass="ui-commandlink-fa ui-widget-fa fa fa-remove" 
									style="margin-left:5px" update="rightForm:plist :form1:msgs"
									actionListener="#{personAndEquipmentDistributeController.removeGovernor(pd)}" >
									<p:confirm header="提示" message="确定移除该管理者吗?" icon="ui-icon-alert" />
								</p:commandLink>  
							</div>
						</p:repeat>
					</p:column>
				</p:dataTable>
			</h:form>
			<h:form id="dialogForm">
				<p:dialog id="addGovernorDialog" widgetVar="addGovernorDialog"
					modal="true" closable="true" draggable="false" header="选择管理人员"
					width="600" height="650">
					<p:outputPanel id="personCol" style="width:600px;height:120px">
						<h:outputText value="已有管理人员：" style="float:left"/>
						<br/>
						<p:repeat var="pe" value="#{personAndEquipmentDistributeController.existPersonList}">
				      		<div style="float:left;width:80px">
					      		<h:outputText value="#{pe.name}"/>
							</div>
						</p:repeat>
						<br/><br/>
						<h:outputText value="新选管理人员：" style="float:left"/>
						<br/>
						<p:repeat var="person" value="#{personAndEquipmentDistributeController.selectedPersonList}">
				      		<div style="float:left;width:80px">
					      		<h:outputText value="#{person.name}"/>
								<p:commandLink title="移除人员" styleClass="ui-commandlink-fa ui-widget-fa fa fa-remove" 
									style="margin-left:5px" update="dialogForm:personCol"
									actionListener="#{personAndEquipmentDistributeController.removeSelectPerson(person)}" />  
							</div>
						</p:repeat>
					</p:outputPanel>
					<p:toolbar>
						<f:facet name="left">
							<p:commandButton value="保存" icon="fa fa-floppy-o"
								actionListener="#{personAndEquipmentDistributeController.save}"
								update=":rightForm:plist :rightForm:addBtn :rightForm:deleteBtn :form1:msgs"
								oncomplete="PF('addGovernorDialog').hide()" />
						</f:facet>
					</p:toolbar>
					<p:tree
						value="#{personAndEquipmentDistributeController.personRoot}"
						var="node" dynamic="true" id="orgTree" widgetVar="orgTree"
						animate="true" selectionMode="multiple" style="border:0">
						<p:ajax event="expand" update="orgTree"
							listener="#{personAndEquipmentDistributeController.onOrgNodeExpand}" />
						<p:ajax event="select" update="dialogForm:personCol"
							listener="#{personAndEquipmentDistributeController.onOrgNodeSelect}" />
						<p:ajax event="unselect" update="dialogForm:personCol"
							listener="#{personAndEquipmentDistributeController.onOrgNodeUnSelect}" />
						<p:treeNode type="dept" icon="fa fa-home">
							<h:outputText value="#{node}" />
						</p:treeNode>
						<p:treeNode type="personnel" icon="fa fa-user">
							<h:outputText value="#{node}" />
						</p:treeNode>
					</p:tree>
				</p:dialog>
			</h:form>
		</div>
	</ui:define>
	<ui:define name="contentend">
	</ui:define>
</ui:composition>